home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / Script Tools / Examples / File IO Example < prev    next >
Text File  |  1993-09-24  |  832b  |  25 lines

  1. --
  2. --    Ask the user to for the name and location of the new file
  3. --
  4. set newFile to choose new file with prompt "Pick a new file name:"
  5. set newFilePath to (folder returned of newFile as string) & (name returned of newFile)
  6.  
  7. --
  8. --    If the file already exists delete it
  9. --
  10. if (replacing of newFile) then ¬
  11.     delete file alias newFilePath
  12.  
  13. --
  14. --    Create the file and write some data to it
  15. --
  16. create file (filename returned of newFile) in (folder returned of newFile) ¬
  17.     owner "ttxt" -- TeachText
  18. set refNum to open file alias newFilePath
  19. write file refNum text "This file is an example of a simple text file which can be created using the File I/O AppleScript additions provided in Script Tools"
  20. write file refNum text ""
  21. write file refNum text "-Mark"
  22. close file refNum
  23. --
  24. --    Note how TeachText treats each line as a seperate paragraph.
  25. --